package mobi.hami.huapin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import mobi.hami.huapin.base.Result;
import mobi.hami.huapin.constants.BaseEnums;
import mobi.hami.huapin.dto.ProductForUserDTO;
import mobi.hami.huapin.model.base.PageVO;
import mobi.hami.huapin.service.HpShareLogService;
import mobi.hami.huapin.util.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 分享记录
 *
 * @author 阿飞 jijunjian@hami.mobi
 * @date 10/8/2018 8:25 PM
 */

@RequestMapping(value = "/sharelog",produces = "application/json")
@Api(description = "花拼分享记录")
@RestController
public class HpShareLogController  {

    @Autowired
    private HpShareLogService shareLogService;

    @RequestMapping(value = "/share.do", method = RequestMethod.POST)
    @ApiOperation(value = "分享", notes = "{\n" +
            "  \"share_user_id\": \"会员编号\",\n" +
            "  \"sn\": \"前端生成guid\",\n" +
            "  \"from_tag\": \"分享源头标签：1，首页，2，订单成功，3，纸条\",\n" +
            "  \"from_page\": \"分享页面名称\"\n" +
            "}")
    public Result share(@RequestBody Map<String, String> reqMap) {

        int rs = shareLogService.share(reqMap);

        return Results.successWithData(rs, BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
    }

    @RequestMapping(value = "/enter.do", method = RequestMethod.POST)
    @ApiOperation(value = "从分享进入系统", notes = "{\n" +
            "  \"user_id\": \"会员编号\",\n" +
            "  \"sn\": \"分享出去的sn,带回来\"\n" +
            "}")
    public Result enter(@RequestBody Map<String, String> reqMap) {

        int rs = shareLogService.enterFromShare(reqMap);

        return Results.successWithData(rs, BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
    }
}
